# Makefile

INS_DIR	:= ../../bin/

TARGET	:= mkmbrimg

CFLAGS	+= -Wall -O2 -Wno-sign-compare -Wno-unused-result
LDFLAGS	+= -lstdc++ -Wl,--as-needed

SRCS	:= $(wildcard *.cpp)
OBJS	:= $(patsubst %.cpp,%.o,$(SRCS))

all:$(TARGET)

$(TARGET):$(OBJS)
	$(CC) -o $@ $^ $(LDFLAGS)
	$(STRIP) $@

%.o:%.c
	$(CC) -c -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o $@ $< $(CFLAGS)

%.o:%.cpp
	$(CXX) -c -c -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o $@ $< $(CFLAGS)

sinclude $(SRCS:.cpp=.d)

install:
	test -d $(INS_DIR) || install -m 755 -d $(LIBDIR)
	install -m 755 $(TARGET) $(INS_DIR)
	
clean:
	@rm -rf *.o *.d $(TARGET)
